<?php /* Smarty version 2.6.26, created on 2018-07-25 19:14:00
         compiled from E:%5CWWW%5C40.125.208.171%5Cvweb/member%5Ctemplates/xuq/edit.html */ ?>
<style type="text/css"> 
table.etable tr td select{ float:left; }
table.etable tr td em{ font-style:inherit; padding:10px 0 0 10px; color:#FF0000; float:left;}

</style>
<style type="text/css">
.cname{ font-size:16px; border-bottom:1px solid #efefef; width:940px; padding:2px 0 10px 0; float:left; }
.cats_list{ width:780px; height:400px; float:left; overflow:hidden; margin:15px 0 0 70px; border:1px solid #efefef; float:left;}
.cats_list .menu{ width:260px; height:400px; padding:0; overflow-y:scroll; float:left;}
.cats_list .menu ul{}
.cats_list .menu ul li{}
.cats_list .menu ul li a{ width:198px; padding:8px 0 8px 20px; font-size:14px; float:left;}
.cats_list .menu ul li.ch{ padding-right:25px; background: #E5F5FD; float:left; }
.cats_list .menu ul li.ch a{ font-weight:bold; color:#1683B6; }

.addBtton{ width:1880px; text-align:center; padding:10px 0 30px;  float:left;}
.addBtton input{ float:none; margin:20px 0 0 0; padding:8px 38px; border-radius:1px; background: #efefef; color:#666; font-size:16px;} 
.addBtton input.ch{ background: #3399CC; color:#FFFFFF; }

.guize{ width:89px; height:180px; color:#888; border:1px solid #efefef; margin:0 0 30px 18px; padding:10px; line-height:25px; overflow-y:scroll; float:left;}
.guige{width: 880px;background: #eee;padding: 20px;display: none;}
.guige li{height: auto;overflow: hidden;}
table.etable .guige li p{ padding-left: 0;height: auto;overflow: hidden;}
.guige li ol{width: 100%;background: #fff;height: auto;overflow: hidden;margin-bottom: 15px;}
.guige li ol li{float: left;width:150px ;height: 30px;line-height: 30px;}
.guige li ol li input{height: 15px;width: 15px;border: 2px solid #eee;margin:8px 5px 0 5px;display: block;float:left;border-radius: 2px;cursor: pointer;}
.guige li ol li b{float: left;font-weight: normal;}
.guige1 input{    border: 1px solid #DDD;padding: 8px;border-radius: 2px;width: 239px;}
.dg_box_bar{position: absolute;}
.guige2{display: none;}
</style>
<table class="etable">
	<tr>
		<td width="90">需求标题：</td>
		<td><input type="text" name="title" id="title" size="38" value="<?php echo $this->_tpl_vars['row']['title']; ?>
" placeholder="需求标题"/><em>*</em></td>
	</tr>

	<tr>
		<td>需求商品分类：</td>
		<td>
<div class="lbox"> 
<form action="?m=company&a=base_save" method="get">	
	<div class="cats_list"></div> 
	<input type="hidden" name="m" value="goods"/>
	<input type="hidden" name="cid" id="cid" value="<?php if ($_GET['cid']): ?><?php echo $_GET['cid']; ?>
<?php endif; ?>"/>
	<input type="hidden" name="a" value="edit"/>
	<?php if ($_GET['gid']): ?>
		<input type="hidden" name="id" id="gid" value="<?php echo $_GET['gid']; ?>
"/>
	<?php endif; ?>
	
	
</form> 
</div></td>
	</tr>
	<tr class="guige2">
			<td style="padding-top:10px;" valign="top">规格：</td>
			<td>
				<ul class="guige">
					
				</ul>
				<div class="guige1">
					
				</div>
			</td> 
		</tr>
	<tr>
		<td>邮编：</td>
		<td><input type="text" name="" id="recive_zip" size="38" value="<?php echo $this->_tpl_vars['row']['zip']; ?>
" placeholder="收件人邮编"/></td>
	</tr>

</table> 
<script type="text/javascript">
$(function(){
	$(document).on("click",".menu ul li a",function(){
		var $this = $(this);
 		var cid = $this.attr('data-cid'); 
		$this.parent('li').addClass('ch').siblings().removeClass('ch');
		$this.parents('.menu').nextAll().remove();
		category_next(cid);
 	}); 
	function category_next(pcid){ 
		cid = cid?cid:'0';
		$.post('member.php?m=xuq&a=ajax_get_next_list',{pcid:pcid}, function(result){
			var data = jQuery.parseJSON(result);
			if(data.error == '0'){
				if(data.last == '0'){
					html = '<div class="menu menu_'+cid+'"><ul>';
					$.each(data.category, function(key, val){
						html += '<li><a href="javascript:;" data-cid="'+val.cid+'" >'+val.name+'</a></li>'; 
					});
					html += '<ul></div>';
					if($('.menu').length == 0){ 
						$('.cats_list').html(html);		
					}else{
					
						$('.menu:last').after(html);		
					} 
					$("#cid").val('');
					$("#submit_cats").attr('disabled',true).removeClass('ch');
						
						
						
				}else{
					$('.guige2').show();
					$("#cid").val(pcid);
					$("#submit_cats").attr('disabled',false).addClass('ch'); 
					$.post('member.php?m=xuq&a=ajax_get_gg',{pcid:pcid}, function(result){
						var data = jQuery.parseJSON(result);
						if(data==null){
						$('.guige').hide();
						$('.guige1').show();
							html="";
							html+='<input type="text" placeholder="请输入规格"/>'
							$('.guige1').html(html);
						}else if(data.error == '0'){
							$('.guige1').hide();
							$('.guige').show();
//							alert(data.category.length);
							var a = data.category;
//							alert(a[0].yiji.erji.length)
							html = "";
							for(var i=0;i<a.length;i++){
								html+='<li><p>'+a[i].yiji.name+'</p><ol>'
								for(var k=0;k<a[i].yiji.erji.length;k++){
									var b = a[i].yiji.erji;
									html+='<li><input type="checkbox" /><b>'+ b[k].name +'</b></li>'
								}
								html+='</ol></li>'
							}
							$('.guige').html(html)
						}
						
						
						
					});
//					alert(pcid);
				} 
			}else{
				alert('系统繁忙');
			}
		}); 
	}
	<?php if ($_GET['cid']): ?>
		$.post("member.php?m=goods&a=ajax_get_parents_list",{cid:'<?php echo $_GET['cid']; ?>
'},function(result){ 
			var data = jQuery.parseJSON(result); 
			html = '';
			$(data).each(function(key, val){
				html += '<div class="menu"><ul>';
				$.each(val.list, function(index, obj){
					if(obj.cid == val.cid){
						html += '<li class="ch"><a href="javascript:;" data-cid="'+obj.cid+'">'+obj.name+'</a></li>'; 
					}else{
						html += '<li><a href="javascript:;" data-cid="'+obj.cid+'" >'+obj.name+'</a></li>'; 
					} 
				}); 
				html += '<ul></div>'; 
			});
			$('.cats_list').html(html); 
		});
		$("#cid").val('<?php echo $_GET['cid']; ?>
'); 
		$("#submit_cats").attr('disabled',false).addClass('ch'); 
		
	<?php else: ?>
		category_next('0');	
	<?php endif; ?> 
});
</script>


<script type="text/javascript" src="<?php echo $this->_tpl_vars['__PUBLIC__']; ?>
js/area.js"></script>


<script type="text/javascript">
	<?php if ($this->_tpl_vars['row']['prov'] == '' && $this->_tpl_vars['row']['city'] == '' && $this->_tpl_vars['row']['dist'] == ''): ?>
		$(".area_box").area();
	<?php else: ?>
		$(".area_box").area({ 
			'prov':'<?php echo $this->_tpl_vars['row']['prov1']; ?>
',
			'city':'<?php echo $this->_tpl_vars['row']['city']; ?>
',
			'dist':'<?php echo $this->_tpl_vars['row']['dist']; ?>
'
		});	
	<?php endif; ?> 
	function ajax_submit(){ 
		var name = $("#recive_name").val(); 		if(name == '')	{ 	alert('姓名不能为空！');	return false; }
		var mobile = $("#recive_mobile").val();		if(mobile == ''){ 	alert('电话不能为空！');	return false; }
		var prov = $("#prov").val();		if(dist == '0')	{ 	alert('选择省份！');		return false; } 
		var city = $("#city").val();		if(city == '0')	{ 	alert('选择市区！');		return false; } 
		var dist = $("#dist").val(); 		if(dist == '0')	{ 	alert('选择县级！');		return false; } 
		var address = $("#recive_address").val();	if(address == ''){ 	alert('地址不能为空！');	return false; } 
		var zip = $("#recive_zip").val(); 
		if(zip){
			if(!/^[0-9][0-9]{5}$/.test(zip)){ 
				$.alert('邮编格式不正确！');  
				return false; 
			}
		} 
		var is_default = $("#recive_is_default").is(':checked')?'1':'0'; 
		$.post('member.php?m=xuq&a=edit_save',{<?php if ($this->_tpl_vars['row']['id']): ?>id:<?php echo $this->_tpl_vars['row']['id']; ?>
,<?php endif; ?>name:name,mobile:mobile,prov:prov,city:city,dist:dist,address:address, zip:zip, is_default:is_default},function(result){ 
			var data = jQuery.parseJSON(result); 
			if(data.error =='0'){
				<?php if ($_GET['type'] == '1'): ?>
					con_html = '<label>'+
									'<span>送至</span>'+
									'<input type="radio" name="address_id" value="'+data.id+'"/>'+
									'<p>'+data.prov_cn+' '+data.city_cn+' '+data.dist_cn+' '+data.address+' ( '+name+' 收) '+data.mobile+'</p>'+
								'</label>'+
								'<div class="rt">'+ 
									'<a href="javascript:;" addrid="'+data.id+'" onClick="address_edit(\'添加地址\',\'member.php?m=address&a=edit&type=1&id='+data.id+'\')">编辑</a> '+
									'<a href="javascript:;" addrid="'+data.id+'" class="address_del">删除</a> '+
								'</div>'; 
					div_num = $('.addr_box').length;
					if(div_num == '0'){ 
						$(".addr_box").html('<div class="addr_box add_con_'+data.id+'">'+con_html+'</div>'); 
					}else{ 
						<?php if ($this->_tpl_vars['row']['id']): ?>
							$(".add_con_"+data.id).html(con_html);  
						<?php else: ?>
							$(".add_con:last-child").after('<div class="addr_box add_con_'+data.id+'">'+con_html+'</div>');
						<?php endif; ?>
					} 
					$('.add_con_'+data.id+' input[name=address_id]').attr("checked","checked"); 
					ajax_close(); 
				<?php else: ?>
					$.alert('保存成功', function(){
						location.reload(); 
					});
				<?php endif; ?>
			}else{
				$.alert(data.msg);
			} 
		}); 
	}
</script>